<template>
	<view class="page">
		<u-image show-loading :src="$imageOss(detail.image)" width="100%" height="248px" @click="preImage" />
		<view class="body">
			<view class="title">
				<view class="">
					{{detail.title}}
				</view>
				<!-- <view class="" style="color: red;font-size: 30rpx;">
					￥{{detail.price}}
				</view> -->
			</view>

			<view class="base">
				<view class="box">
					<view class="" style="display: flex;">
						<u-icon name="eye"></u-icon>
						<view class="">{{detail.read}}</view>
					</view>
				</view>
			</view>
			<view class="" style="padding: 20rpx 0;border-bottom: 2rpx solid #D9D9D980;">
				<view class="" v-for="(t,index) in typeList">
					<u-text v-if="detail.market_category_id == t.id" :text="`产品分类 : ${t.name}`" lines="1"
						line-height="48rpx" color="#909090" size="26rpx" />
				</view>

				<u-text :text="`发布时间 : ${detail.createtime}`" lines="1" line-height="48rpx" color="#909090"
					size="26rpx" />
			</view>

			<view class="" style="display: flex;align-items: center;">
				<view class="leftIcon"></view>
				<Sub-title label="详细信息" />
			</view>

			<u-parse :content="detail.content" style="color: #909090;font-size: 26rpx;" />

			<!-- <view class="" style="display: flex;align-items: center;">
				<view class="leftIcon"></view>
				<Sub-title label="评论" />
			</view>
			<remark :page="page" @lastPage="lastPage" v-if="detail.id" :typeId="detail.id" :type="3" :adminId="detail.admin_id" /> -->
		</view>
		<!-- <view class="bott">
			<Foot path="/pages/home/orderDetails" :comment="detail.count" :like="detail.like" :collect="detail.collect"
				:type="3" :width="680" :per="14" :is_like="detail.is_like" :is_collect="detail.is_collect"
				:is_id="detail.id" @like="handleLike"></Foot>
		</view> -->
	</view>
</template>

<script>
	import Navbar from "@/components/Navbar/index";
	import remark from "@/components/remark/index";
	import Foot from "@/components/footer/index";

	import {
		marketDetail,
		marketCategory
	} from "@/request/homeApi.js";
	export default {
		components: {
			Navbar,
			remark,
			Foot
		},
		data() {
			return {
				typeList: [],
				detail: {},
				page:1,
				last_page:1
			};
		},
		onLoad(e) {
			this.getTypeList();
			this.getDetails(e.id);
		},
		onReachBottom() {
			let that = this
			if (that.page < that.last_page) {
				that.page = that.page + 1
			}
		},
		computed: {},
		// 监听页面滚动
		onPageScroll(scroll) {
			uni.$emit("onPageScroll", scroll.scrollTop);
		},
		methods: {
			
			lastPage(e){
				this.last_page = e
			},
			// 获取赶大集分类
			getTypeList() {
				let that = this
				marketCategory().then(res => {
					if (res.code == 200) {
						that.typeList = res.data
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1500,
							icon: 'none',
						})
					}
				})
			},
			// 点赞/收藏
			handleLike(v) {
				this.getDetails(v)
			},
			Jump(url) {
				uni.navigateTo({
					url: url
				})
			},
			// 预览图片
			preImage() {
				uni.previewImage({
					urls: [this.detail.cover_img],
				});
			},
			// 点击拨号
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.detail.phone,
				});
			},
			// 跳转地图
			handleMap() {
				// let result = this.$store.dispatch("permission/requestPermissions",
				// 	'ACCESS_FINE_LOCATION')
				// if (result !== 1) return
				
				const {
					lat,
					lng,
					address
				} = this.detail;
				// uni.openLocation({
				//   latitude: lat,
				//   longitude: lng,
				//   address: address,
				//   scale: 16,
				// });
				uni.navigateTo({
					url: `/pages/parse/map?lat=${lat}&lng=${lng}`
				});
			},
			// 获取详情
			getDetails(id) {
				marketDetail({
					id
				}).then((res) => {
					if (res.code == 200) {
						this.detail = res.data;
					} else {
						uni.showToast({
							title: res.msg,
							duration: 1500,
							icon: 'none',
						})
					}
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.page {
		.leftIcon {
			width: 6rpx;
			height: 30rpx;
			margin-right: 10rpx;
			background: #47578E;
		}

		.bott {
			position: fixed;
			bottom: 0;
			left: 0;
			height: 110rpx;
			background: #fff;
			width: 100%;
			display: flex;
			align-items: center;
			padding: 30rpx 40rpx 40rpx;
			justify-content: space-between;
			box-shadow: 0 0 10rpx rgba(228, 228, 228, 0.5);
			box-sizing: border-box;
			z-index: 2;

			.button {
				width: 35%;
				height: 70rpx;
				padding: 0 28rpx;
				box-sizing: border-box;
				margin-left: 20rpx;
				text-align: center;
				line-height: 70rpx;
				color: #fff;
				font-size: 28rpx;
				background-color: $active-color;
				border-radius: 10rpx;
			}
		}

		.body {
			width: 100%;
			padding: 20rpx 24rpx;
			min-height: 100rpx;
			box-sizing: border-box;
			background-color: #ffffff;
			margin-top: -14rpx;
			padding-bottom: 140rpx;

			.title {
				display: flex;
				justify-content: space-between;
				height: 68rpx;
				line-height: 68rpx;
				font-size: 32rpx;
				align-items: center;
			}

			.base {
				.box {
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 24rpx;
					color: #B6B6B6;
					padding-bottom: 20rpx;
					border-bottom: 2rpx solid #D9D9D980;
				}
			}

			.tabBox {
				width: 100%;
				box-sizing: border-box;
				font-size: 30rpx;

				.navItem {
					padding: 10rpx 20rpx 0;
					width: 24.33%;
					text-align: center;
					box-sizing: border-box;

					.image {
						width: 100rpx;
						height: 100rpx;
						border-radius: 50%;
					}
				}
			}

			.remarkBox {
				width: 100%;
				box-sizing: border-box;
				font-size: 28rpx;
				color: #909090;

				.navItem {
					width: 98%;
					text-align: center;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					margin: 20rpx auto;

					.image {
						width: 56rpx;
						height: 56rpx;
						border-radius: 50%;
						margin-right: 16rpx;
					}
				}
			}


			.card-item {
				width: 100%;
				height: 240rpx;
				margin: 10rpx 0;
				background-size: 100% 100%;
				padding: 0 40rpx;
				display: flex;
				box-sizing: border-box;
				align-items: center;

				>view:first-child {
					flex: 1;
				}

				>view:last-child {
					width: 172rpx;
					height: 140rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: space-around;

					.price {
						color: #ff3e3e;

						>text:first-child {
							font-size: 28rpx;
						}

						>text:nth-child(2) {
							font-size: 24rpx;
						}

						>text:last-child {
							font-size: 40rpx;
						}
					}

					.btn {
						width: 172rpx;
						height: 56rpx;
						color: #fff;
						font-size: 28rpx;
						line-height: 56rpx;
						text-align: center;
						border-radius: 28rpx;
						background-color: $active-color;
					}

					.disabled {
						color: #f9f9f9;
						background-color: #dbdbdb;
					}
				}
			}
		}
	}
</style>
